package com.fenghuajueli.module_find_the_difference.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.fenghuajueli.module_find_the_difference.R;

public class AnswerCorrectDialog extends Dialog {
    private TextView tvBack,tvNext,tvTitle;
    private OnAnswerCorrectListener listener;
    private Context context;

    public AnswerCorrectDialog(Context context, OnAnswerCorrectListener listener) {
        super(context, R.style.ResultDialog);
        this.listener = listener;
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_answer_correct);
        setCanceledOnTouchOutside(false);

        Window window = getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.CENTER;
        window.setAttributes(params);

        initView();
        initListener();
    }

    private void initView() {
        tvBack = findViewById(R.id.tv_cancel);
        tvNext = findViewById(R.id.tv_next);
        tvTitle = findViewById(R.id.tv_title);
        Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/baotuxiaobaiti.ttf");
        tvTitle.setTypeface(tf);
    }


    private void initListener() {
        tvBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.back();
                dismiss();
            }
        });
        
        tvNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.next();
                dismiss();
            }
        });
    }

    public interface OnAnswerCorrectListener {
        void back();

        void next();
    }
}
